Skip to content

Update custom controls sample and migrate to new repo#1121

Open
sascala wants to merge 3 commits intomainfrom
control-custom-update
Open

Update custom controls sample and migrate to new repo#1121
sascala wants to merge 3 commits intomainfrom
control-custom-update

Conversation

@sascala
Copy link

@sascala sascala commented Feb 20, 2026

Update custom controls sample and migrate to new repo

@snippet-bot
Copy link

snippet-bot bot commented Feb 20, 2026

Here is the summary of changes.

You are about to add 11 region tags.

This comment is generated by snippet-bot.
If you find problems with this result, please file an issue at:
https://github.com/googleapis/repo-automation-bots/issues.
To update this comment, add snippet-bot:force-run label or use the checkbox below:

  • Refresh this comment

Copy link
Collaborator

@willum070 willum070 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you so much, this totally makes my day!! A great start, but there are a few things to clean up. Specifically there's a refactor I'd like to see done for all migrations where it makes sense (see my comments and use #1119 for reference).

Also please make sure your PR doesn't contain any changes to dist/, as that stuff gets generated automatically once your changes are merged.

/**
* Creates a control that recenters the map on Chicago.
*/
function createCenterControl(map) {
Copy link
Collaborator

@willum070 willum070 Feb 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here is where the fun begins! My practice has been to refactor things to be declarative rather than generate UI programmatically. Here are the steps I'd recommend:

  • Take the CSS definitions from the createCenterControl() function and move them into a new CSS style.
  • Nest the button element in the gmp-map element and use the slot attribute to position it.
  • Within initMap(), add code to get the button element from the HTML.
  • Move the event handler for the button into initMap().
  • Remove the createCenterControl() function.
  • Remove the injection code on ln. 61 - ln. 68, as it's not needed now that you've got HTML.

See #1119 for reference.

Co-authored-by: William French <wfrench@google.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants